﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Threading;
using System.Globalization;
using Nivdal.AuxCode;

namespace Nivdal
{
    public partial class TrainingReports : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!HttpContext.Current.User.Identity.IsAuthenticated)
                Response.Redirect("~/Default.aspx");
            this.Title = Resources.Resource.Default_PageTitle + ", " + Resources.Resource.TrainingReports_PageTitle;
            GetNivdalData.GetNivdalData GND = new GetNivdalData.GetNivdalData();
            OnlineUser ou = (OnlineUser)Session["User"];
            
            this.Title = Resources.Resource.TrainingReports_Title + " - " + GND.ReturnAppTitle();
            
            if (ou.TeamId == "Null")
                Response.Redirect("~/GeneralMessage.aspx?MessageString=M74ggdizz5wfeh");

            if (!IsPostBack)
            {
                this.TrainingReportsDataSourse.SelectParameters.Add("UserId", ou.UserId);
                this.TrainingOldReportsDataSourse.SelectParameters.Add("UserId", ou.UserId);
                this.TrainingAutomaticReportsDataSourse.SelectParameters.Add("TeamId", ou.TeamId);
                this.TrainingAutomaticReportsDataSourse.SelectParameters.Add("Language", ou.Language);
            }
            this.OlderTrainingReportsPanel.Visible = (this.TrainingOldReportsGridView.Rows.Count > 0);
            this.AutomaticTrainingPanel.Visible = (this.AutomaticTrainigGridview.Rows.Count > 0);
            try
            {
                TrainingDataGridView.UseAccessibleHeader = true;
                TrainingDataGridView.HeaderRow.TableSection = TableRowSection.TableHeader;

                TrainingOldReportsGridView.UseAccessibleHeader = true;
                TrainingOldReportsGridView.HeaderRow.TableSection = TableRowSection.TableHeader;

                AutomaticTrainigGridview.UseAccessibleHeader = true;
                AutomaticTrainigGridview.HeaderRow.TableSection = TableRowSection.TableHeader;
            }
            catch { }
        }

        protected override void InitializeCulture()
        {
            OnlineUser ou = (OnlineUser)Session["User"];
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(ou.UICulture);
            Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(ou.Culture);
        }
    }
}